package offer;

import java.util.Stack;

public class CQueue_09 {
    Stack<Integer> stack1 = new Stack<>();
    Stack<Integer> stack2 = new Stack<>();

    public CQueue_09() {

    }

    public void appendTail(int value) {
        stack1.add(value);
    }

    public int deleteHead() {
        if(!stack2.empty()){
            return stack2.pop();
        }else if(stack1.isEmpty()){
            return -1;
        }else{
            while (!stack1.isEmpty()){
                stack2.add(stack1.pop());
            }
            return stack2.pop();
        }
    }

    Stack<Integer> stack3 = new Stack<>();
    Stack<Integer> stack4 = new Stack<>();

    public void appendTail2(int value){
        stack3.add(value);
    }

    public int deleteHead2() {
        if(!stack4.isEmpty()){
            return stack4.pop();
        }else if(stack3.isEmpty()){
            return -1;
        }else{
            while (!stack3.isEmpty()){
                stack4.add(stack3.pop());
            }
            return stack4.pop();
        }
    }



}
